package fr.orleans.publique;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import entities.Player;
import entities.Team;
import fr.orleans.tools.JSFServices;
import fr.orleans.tools.ManagedBeans;

@ManagedBean
@ViewScoped
public class TeamDetail extends ManagedBeans{

	private Team oneTeam;
	private List<Player> listPlayer;

	public TeamDetail(){
		try{
			this.oneTeam = (Team) JSFServices.getParameterInRequestMap("team");
		}catch(Exception e){
			
		}
	}
	public Team getOneTeam() {
		if(this.oneTeam == null)
			this.oneTeam = (Team) JSFServices.getParameterInRequestMap("team");
		
		return oneTeam;
	}

	public void setOneTeam(Team oneTeam) {
		this.oneTeam = oneTeam;
	}
	
	public List<Player> getListPlayer() {
		if(this.listPlayer == null)
			this.listPlayer = new ArrayList<>(this.oneTeam.getListPlayers());
			
		return listPlayer;
	}
	
	public void setListPlayer(List<Player> listPlayer) {
		this.listPlayer = listPlayer;
	}
	
	public String goBackToDetailTournament(){
		JSFServices.putParameterInRequestMap("tournament", this.oneTeam.getTournament());
		return "/modules/public/detailTournament.jsf";
	}
}